<include file="public@header"/>
<style>
.breadcrumb {
  padding: 8px 15px;
  margin-bottom: 20px;
  list-style: none;
  background-color: #f5f5f5;
  border-radius: 4px;
  font-size: 20px;
}
.breadcrumb > li + li:before {
    color: #CCCCCC;
    content: "-> ";
    padding: 0 5px;
	font-size: 30px;
}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ol class="breadcrumb">
		<li><a href="{:url('Classroom/campus')}">{$param['campus_name']}</a></li>
		<li class="active">教室管理</li>
	</ol>
	<if condition="isset($classroom_info)">
	<form class="js-ajax-form" action="" method="post">
        <div class="table-actions">
			<input class="btn btn-primary" type="button" value="返回" onclick="javascript:history.back(-1)"></input>
            <input id="add_classroom" class="btn btn-primary" type="button" value="新增教室"></input>
            <input id="edit_classroom" class="btn btn-primary" type="button" value="编辑教室"></input>
            <!-- <input id="article_classroom" class="btn btn-primary" type="button" value="查看页面"></input> -->
            
            <!-- <button id="delete_classroom" class="btn btn-danger js-ajax-submit" type="submit" style="float:right" -->
                    <!-- data-action="{:url('classroom/delete_classroom')}" data-msg="您确定删除吗？">删除 -->
            <!-- </button> -->
        </div>
		
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>教室ID</th>
                <th>教室名称</th>
                <th>所属校区</th>
                <th>座位情况</th>
                <th>容纳人数</th>
                <th>考试人数</th>
                <th>教室地图</th>
            </tr>
            </thead>
            <foreach name="classroom_info" item="vo">
                <tr name='{$vo.id}'>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}" title="ID:{$vo.id}">
                    </td>
                    <td><b>{$vo.id}</b></td>
                    <td>{$vo.name}</td>
                    <td>{$vo.campus_id|default='未知'}</td>
                    <td>{$vo.seat_view|default='未知'}</td>
                    <td>{$vo.max_count|default='未知'}</td>
                    <td>{$vo.exam_count|default='未知'}</td>
                    <td>
						<if condition="$vo['map_img']!=''">
							<img src="{:cmf_get_image_preview_url($vo['map_img'])}" height="40px;" onclick="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo['map_img'])}');"></img>
						<else>
							暂无教室地图
						</if>
					</td>
                </tr>
            </foreach>
        </table>
        <ul class="pagination">{$page|default=''}</ul>
	</form>
	</if>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	$(function(){
	<!-- 新增教室 -->
	$("#add_classroom").click(function(){
		var url = "{:url('Classroom/add_classroom','',false,true)}" + "/id/" + {$param['id']};
		window.location.href = url;
	});
	<!-- 编辑教室 -->
		$("#edit_classroom").click(function(){
			var ids = [];
			$("input[name='ids[]']").each(function () {
				if ($(this).is(':checked')) {
					ids.push($(this).val());
				}
			});
			if (ids.length == 1){
				var url = "{:url('Classroom/edit_classroom','',false,true)}" + "/id/" + ids;
				<!-- alert(url); -->
				window.location.href = url;
			}
			else{
				alert('请选择一个教室进行编辑');
			}
		});
		<!-- 查看教室详情页 -->
		$("#article_classroom").click(function(){
			var ids = [];
			$("input[name='ids[]']").each(function () {
				if ($(this).is(':checked')) {
					ids.push($(this).val());
				}
			});
			if (ids.length == 1){
				var url = "{:url('portal/article/classroom','',false,true)}" + "/id/" + ids;
				window.open(url);
			}
			else{
				alert('请选择一个要查看的教室！');
			}
		});
	});

	$(function(){
		$("tr[name]").click(function(){
			var id = $(this).attr("name");
			var is_check = $("input[value='"+id+"']").prop("checked");
			if(is_check){
				$("input[value='"+id+"']").prop("checked",false);
				$(this).prop("class",false);
			}
			else{
				$("input[value='"+id+"']").prop("checked",true);
				$(this).prop("class","success");
			}
		});
	});
</script>
</body>
</html>